package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.TbFurniture;
import com.ruoyi.system.service.ITbFurnitureService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 家具管理Controller
 * 
 * @author ruoyi
 * @date 2025-02-14
 * 20250213 云计算-宏烨找房-03-王浩宇-家具买卖租赁V1.1
 */
@RestController
@RequestMapping("/furniture")
public class TbFurnitureController extends BaseController
{
    @Autowired
    private ITbFurnitureService tbFurnitureService;

    /**
     * 查询家具管理列表
     * 20250213 云计算-宏烨找房-03-王浩宇-家具买卖租赁V1.1-查询家具管理列表
     */
    @RequiresPermissions("system:furniture:list")
    @GetMapping("/list")
    public TableDataInfo list(TbFurniture tbFurniture)
    {
        startPage();
        List<TbFurniture> list = tbFurnitureService.selectTbFurnitureList(tbFurniture);
        return getDataTable(list);
    }

    /**
     * 导出家具管理列表
     * 20250213 云计算-宏烨找房-03-王浩宇-家具买卖租赁V1.1-导出家具管理列表
     */
    @RequiresPermissions("system:furniture:export")
    @Log(title = "家具管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbFurniture tbFurniture)
    {
        List<TbFurniture> list = tbFurnitureService.selectTbFurnitureList(tbFurniture);
        ExcelUtil<TbFurniture> util = new ExcelUtil<TbFurniture>(TbFurniture.class);
        util.exportExcel(response, list, "家具管理数据");
    }

    /**
     * 20250213 云计算-宏烨找房-03-王浩宇-家具买卖租赁V1.1-获取家具管理详细信息
     */
    @RequiresPermissions("system:furniture:query")
    @GetMapping(value = "/{furnitureId}")
    public AjaxResult getInfo(@PathVariable("furnitureId") Long furnitureId)
    {
        return success(tbFurnitureService.selectTbFurnitureByFurnitureId(furnitureId));
    }

    /**
     *
     * 20250213 云计算-宏烨找房-03-王浩宇-家具买卖租赁V1.1-新增家具管理
     */
    @RequiresPermissions("system:furniture:add")
    @Log(title = "家具管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbFurniture tbFurniture)
    {
        return toAjax(tbFurnitureService.insertTbFurniture(tbFurniture));
    }

    /**
     * 修改家具管理
     * 20250213 云计算-宏烨找房-03-王浩宇-家具买卖租赁V1.1-修改家具管理
     */
    @RequiresPermissions("system:furniture:edit")
    @Log(title = "家具管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbFurniture tbFurniture)
    {
        return toAjax(tbFurnitureService.updateTbFurniture(tbFurniture));
    }

    /**
     * 删除家具管理
     * 20250213 云计算-宏烨找房-03-王浩宇-家具买卖租赁V1.1-删除家具管理
     */
    @RequiresPermissions("system:furniture:remove")
    @Log(title = "家具管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{furnitureIds}")
    public AjaxResult remove(@PathVariable Long[] furnitureIds)
    {
        return toAjax(tbFurnitureService.deleteTbFurnitureByFurnitureIds(furnitureIds));
    }
}
